<%@page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ page isELIgnored="false"%>
<%
	String path = request.getContextPath();
	System.out.print(path);
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	System.out.print(basePath);
%>
<html>
<head>
<base href="<%=basePath%>">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>TI - dbConfig</title>
<script src="js/jquery.js"></script>
<link rel="stylesheet" href="css/bootstrap.min.css">
<script src="js/bootstrap.min.js"></script>
<script type="text/javascript">
	function deleteDBLink(o) {
		if(window.confirm("确认删除?"))
		window.location.href = "deleteDBLink.action?id=" + o.id;
	}
	function deleteDBSql(o) {
		if(window.confirm("确认删除?"))
		window.location.href = "deleteDBSql.action?id=" + o.id;
	}
	$(document).ready(function() {
		$("#dbLinkSubmit").click(function() {
			$("#dbLinkForm").submit();
		});
		$("#dbSqlSubmit").click(function() {
			$("#dbSqlForm").submit();
		});
	});
</script>
</head>
<body>
	<div class="row clearfix">
		<div class="col-md-12 column">
			<h4>
				 <em class="glyphicon glyphicon-subtitles"></em> DB-SQL相关配置
			</h4>
		</div>
	</div>
	<div class="row clearfix">
		<div class="col-md-6 column">
			<a id="modal-86913" href="#modal-container-86913" role="button"
				class="btn btn-primary" data-toggle="modal">添加DB连接配置</a>

			<div class="modal fade" id="modal-container-86913" role="dialog"
				aria-labelledby="myModalLabel" aria-hidden="true"
				data-backdrop="static">
				<div class="modal-dialog">
					<div class="modal-content">
						<div class="modal-header">
							<button type="button" class="close" data-dismiss="modal"
								aria-hidden="true">×</button>
							<h4 class="modal-title" id="myModalLabel">DB连接配置增加</h4>
						</div>
						<div class="modal-body">
							<form class="form-horizontal" role="form" id="dbLinkForm"
								action="saveDBLink.action" methdo="POST">
								<div class="form-group">
									<label for="inputEmail3" class="col-sm-3 control-label">连接IP</label>
									<div class="col-sm-8">
										<input class="form-control" id="inputEmail3" type="email"
											name="dbLink.ip" />
									</div>
								</div>
								<div class="form-group">
									<label for="inputEmail3" class="col-sm-3 control-label">PORT</label>
									<div class="col-sm-3">
										<input class="form-control" id="inputEmail3" type="email"
											name="dbLink.port" />
									</div>
								</div>
								<div class="form-group">
									<label for="inputEmail3" class="col-sm-3 control-label">数据库类型</label>
									<div class="col-sm-3">
										<select class="form-control" name="dbLink.type">
											<option value="请选择">请选择</option>
											<option value="MYSQL">MYSQL</option>
											<option value="SQLSERVER">SQLSERVER</option>
											<option value="ORACLE">ORACLE</option>
										</select>
									</div>
								</div>
								<div class="form-group">
									<label for="inputEmail3" class="col-sm-3 control-label">数据库名称</label>
									<div class="col-sm-8">
										<input class="form-control" id="inputEmail3" type="email"
											name="dbLink.dbName" />
									</div>
								</div>
								<div class="form-group">
									<label for="inputEmail3" class="col-sm-3 control-label">用户名</label>
									<div class="col-sm-8">
										<input class="form-control" id="inputEmail3" type="email"
											name="dbLink.userName" />
									</div>
								</div>
								<div class="form-group">
									<label for="inputPassword3" class="col-sm-3 control-label">密码</label>
									<div class="col-sm-8">
										<input class="form-control" id="inputPassword3"
											type="password" name="dbLink.password" />
									</div>
								</div>
								<!-- <textarea class="form-control" rows="5" name="dbSql.sql"></textarea> -->
								<div class="form-group">
									<label for="inputPassword3" class="col-sm-3 control-label">备注</label>
									<div class="col-sm-8">
										<textarea class="form-control" rows="3" name="dbLink.remarks"></textarea>
									</div>
								</div>
						</div>
						<div class="modal-footer">
							<button type="reset" class="btn btn-default">重置</button>
							<button type="submit" class="btn btn-primary" id="dbLinkSubmit"
								data-dismiss="modal">提交</button>
						</div>
						</form>
					</div>

				</div>

			</div>

			<table class="table table-hover table-condensed table-striped">
				<thead>
					<tr>
						<th>ID</th>
						<th>类型</th>
						<th>IP</th>
						<th>端口</th>
						<th>库名</th>
						<th>账户</th>
						<th>密码</th>
						<th>配置人</th>
						<th>操作</th>
					</tr>
				</thead>
				<tbody>
					<s:iterator value="dbLinks" var="dblink">
						<tr>
							<td>db-<s:property value="#dblink.id" /></td>
							<td><s:property value="#dblink.type" /></td>
							<td><s:property value="#dblink.ip" /></td>
							<td><s:property value="#dblink.port" /></td>
							<td><s:property value="#dblink.dbName" /></td>
							<td><s:property value="#dblink.userName" /></td>
							<td><s:property value="#dblink.password" /></td>
							<td><s:property value="#dblink.configer" /></td>
							<td><s:a class="glyphicon glyphicon-remove"
									href="javascript:void(0)" id="%{#dblink.id}"
									onclick="deleteDBLink(this)">
									<em class="glyphicon glyphicon-remove"></em>
								</s:a></td>
							<!-- style="line-height: 35px" -->
						</tr>
					</s:iterator>
				</tbody>
			</table>
		</div>
		<div class="col-md-6 column">
			<a id="modal-504349" href="#modal-container-504349" role="button"
				class="btn btn-primary" data-toggle="modal">添加SQL配置</a>

			<div class="modal fade" id="modal-container-504349" role="dialog"
				aria-labelledby="myModalLabel" aria-hidden="true"
				data-backdrop="static">
				<div class="modal-dialog">
					<div class="modal-content">
						<div class="modal-header">
							<button type="button" class="close" data-dismiss="modal"
								aria-hidden="true">×</button>
							<h4 class="modal-title" id="myModalLabel">SQL配置增加</h4>
						</div>
						<div class="modal-body">
							<form class="form-horizontal" role="form" id="dbSqlForm"
								action="saveDBSql.action" method="POST">
								<div class="form-group">
									<label for="inputEmail3" class="col-sm-2 control-label">DB-ID</label>
									<div class="col-sm-3">
										<s:select cssClass="form-control" name="dbSql.dbLinkId"
											list="dbLinks" listKey="id" listValue="'db-'+id"
											theme="simple">
											<!-- <option>请选择</option> -->
											<%-- <s:iterator value="dbLinks" var="dblink" >
												<option value="%{#dbLink.id}">db-
													<s:property value="#dblink.id" /></option>
											</s:iterator> --%>
										</s:select>
									</div>
								</div>
								<div class="form-group">
									<label for="inputPassword3" class="col-sm-2 control-label">SQL</label>
									<div class="col-sm-8">
										<textarea class="form-control" rows="5" name="dbSql.sql"></textarea>
									</div>
								</div>
						</div>
						<div class="modal-footer">
							<button type="reset" class="btn btn-default">重置</button>
							<button type="submit" class="btn btn-primary" id="dbSqlSubmit"
								data-dismiss="modal">提交</button>
						</div>
						</form>
					</div>
				</div>
			</div>

			<table class="table table-hover table-condensed table-striped">
				<thead>
					<tr>
						<th>ID</th>
						<th>DB-ID</th>
						<th>SQL</th>
						<th>配置人</th>
						<th>操作</th>
					</tr>
				</thead>
				<tbody>
					<s:iterator value="dbSqls" var="dbSql">
						<tr>
							<td>sql-<s:property value="#dbSql.id" /></td>
							<td>db-<s:property value="#dbSql.dbLinkId" /></td>
							<td><s:property value="#dbSql.sql" /></td>
							<td><s:property value="#dbSql.configer" /></td>
							<td><s:a class="glyphicon glyphicon-remove"
									href="javascript:void(0)" id="%{#dbSql.id}"
									onclick="deleteDBSql(this)">
									<em class="glyphicon glyphicon-remove"></em>
								</s:a></td>
						</tr>
					</s:iterator>
				</tbody>
			</table>
		</div>
	</div>
	</div>
</body>
</html>